<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<%@ include file="/common/ssb/include/common-base.jsp" %>
	<title>订单报表统计</title>
	<!-- Tell the browser to be responsive to screen width -->
	<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>

<!-- Part 一、 以下是body主体内容的模块区域 -->
<body class="hold-transition ${sysColor} sidebar-mini">
<div class="wrapper">

	<!-- top start -->
	<%@include file="/common/ssb/top.jsp" %>
	<!-- top end -->
	<!-- left start -->
	<%@include file="/common/ssb/left.jsp" %>
	<!-- left end-->

	<div class="content-wrapper">
		<!-- Main start -->
		<section class="content">
			<div id="div_hidden_content" class="hidden" style="display:none;">
				<input name="templateType" type="hidden" value="search"/>
				<div id="hidden_common_final">
					<!-- temp="hidden_common_final" start -->
					<input name="mainObjName" type="hidden" value="ssInsurPro">
					<input name="mainObjPrimaryKey" type="hidden" value="infoId">
					<input name="objNameAll" type="hidden" value="ssCommissionDetail,ssInsurOrder,ssInsurPro">
					<!-- temp="hidden_common_final" end -->
				</div>
				<!-- temp="delForm_hidden" start -->
				<div id="delForm_hidden"></div>
				<!-- temp="delForm_hidden" end -->
				<div class="form-group">
					<select id="addForm1_ssInsurPro_insurCode" name="ssInsurPro.insurCode" class="form-control  clean"
							data-temp-obj="ssInsurPro.insurCode"
							data-obj-name="ssInsurCpy" data-dict-code="dymicSql" data-type-tag="select"
							data-colmun="{value:'insurCode',text:'insurFullName'}" data-page-name="ss-insur-cpy" data-form-name="searchForm"
							data-condition="" data-def="" data-dict-cate="">
						<option value="">-请选择--</option>
					</select>
				</div>
				<!-- temp="viewForm_hidden" start -->
				<div id="viewForm_hidden" style="display:none;"></div>
				<!-- temp="viewForm_hidden" end -->

				<!-- temp="editForm_hidden" start -->
				<div id="editForm_hidden" style="display:none;"></div>
				<!-- temp="editForm_hidden" end -->
			</div>
			<div class="row">
				<div class="col-xs-12">

					<!------搜索  start ------->
					<div class="box box-info">
						<!--搜索title  start -->
						<div class="box-header with-border">
							<h3 class="box-title"><i class="fa fa-search"></i> 报表统计搜索</h3>
							<div class="box-tools pull-right">
								<button type="button" class="btn btn-box-tool" data-widget="collapse"><i
										class="fa fa-minus"></i></button>
							</div>
						</div>
						<!--搜索title  end -->
						<div class="box-body">
							<form id="searchForm" action="javascript:;">
								<!-- temp="searchForm_hidden" start -->
								<div id="searchForm_hidden" style="display:none;">
									<input type="hidden" name="pageName" value="ss-insur-order-search"/>
									<input type="hidden" name="formName" value="searchForm"/>
									<input type="hidden" name="templateName" value="statisticsOrderOut.xls"/>
									<input type="hidden" name="objName" value="entity"/>
								</div>
								<!-- temp="searchForm_hidden" end -->

								<!-- temp="searchForm_content" start -->
								<div id="searchForm_content" class="form-group" data-temp-code="true"
									 data-temp-type="searchForm" data-temp-form-id="searchForm">


									<table class="table table-bordered bordercolor">
										<tbody>
										<tr>
											<td class="active" align="right"><label
													class="form-control-static">产品名称：</label></td>
											<td>
												<div class="form-group"><input name="ssInsurOrder.wl_agentRiskCname"
																			   class="form-control clean" maxlength="30"
																			   data-temp-obj="ssInsurOrder.agentRiskCname">
												</div>
											</td>
											<td class="active" align="right"><label
													class="form-control-static">保单生成日期起：</label></td>
											<td>
												<div class="form-group">
													<div class="input-group "><input name="ssInsurOrder.createTimeStart"
																					 data-temp-obj="ssInsurOrder.createTime"
																					 data-type-tag="date" maxlength="30"
																					 class="form-control clean datepicker"
																					 readonly="readonly"
																					 type="text"><span
															class="input-group-addon"> <i
															class="fa fa-calendar"></i></span></div>
												</div>
											</td>
											<td class="active" align="right"><label
													class="form-control-static">至：</label></td>
											<td>
												<div class="form-group">
													<div class="input-group "><input name="ssInsurOrder.createTimeEnd"
																					 data-temp-obj="ssInsurOrder.createTime"
																					 data-type-tag="date" maxlength="30"
																					 class="form-control clean datepicker"
																					 readonly="readonly"
																					 type="text"><span
															class="input-group-addon"> <i
															class="fa fa-calendar"></i></span></div>
												</div>
											</td>
										</tr>
										</tbody>
									</table>

								</div>
								<!-- temp="searchForm_content" end -->
							</form>
							<div class="box-footer text-center">
								<button type="button" class="btn btn-success" onclick="getTableData();"
										data-temp-event="searchForm_hidden"><i class="fa fa-search"></i> 查询
								</button>
								 
								<button type="button" class="btn btn-warning"
										onclick="mytools.cleanData('#searchForm');">重置
								</button>
							</div>
						</div>
					</div>
					<!------- 搜索 end -------->

					<!------- 列表 start -------->
					<div class="box box-success">
						<!--列表title  start -->
						<div class="box-header with-border">
							<h3 class="box-title"><i class="fa fa-table"></i> 查询结果
								<button class="btn btn-primary " type="button"
										onclick="toOut();"> <i class="fa fa-download" aria-hidden="true"></i>导 出
								</button>
							</h3>
							<div class="box-tools pull-right">
								<button type="button" class="btn btn-box-tool" data-widget="collapse"><i
										class="fa fa-minus"></i></button>
							</div>
						</div>
						<div class="box-body">
							<table id="dataList" class="table table-bordered table-hover">
								<thead>
								<tr id="dataList_thead_content" data-temp-code="true" data-temp-type="table"
									data-temp-show="dataList_template_content">
									<th>序号</th>
									<!-- temp="dataList_thead_content" start -->
									<!--渠道商、出单会员号、保单号、投保单号、保险公司、产品名称、保单生成时间、保额、保费、佣金-->
									<th >出单会员号</th>
									<th >保单号</th>
									<th >投保单号</th>
									<th >保险公司</th>
									<th >产品名称</th>
									<th >保单生成时间</th>
									<th >保额（元）</th>
									<th >保费（元）</th>
									<!-- temp="dataList_thead_content" end -->
								</tr>
								</thead>
								<tbody id="dataList-body">

								</tbody>
							</table>
						</div>

						<div class="box-footer text-center">
							<ul id="dataList-page" class="pagination">
							</ul>
						</div>
					</div>
					<!------- 列表 end -------->
				</div>
			</div>


			<!-- Part 二、以下是template模板定义的模块区域 -->
			<script type="text/template" id="dataList-template">
				<? for ( var i = 0; i < rows.length; i++) {?>
				<tr>
					<td><?=(pageObj.currentPage-1)*10+(i+1)?></td>
					<!-- temp="dataList_template_content" start -->
					<td><?=strUtil.doNull(rows[i].createUser,'')?></td>
					<td><?=strUtil.doNull(rows[i].policyNo,'')?></td>
					<td><?=strUtil.doNull(rows[i].requestNo,'')?></td>
					<td><?=dictListMap["ss-insur-cpy-searchForm"][strUtil.doNull(rows[i].insurCode,'')]?></td>
					<td><?=strUtil.doNull(rows[i].agentRiskCname,'')?></td>
					<td><?=strUtil.doNull(rows[i].createTime,'')?></td>
					<td class="text-right">￥<?=fmoneyDoNull(rows[i].amount,'')?></td>
					<td class="text-right">￥<?=fmoneyDoNull(rows[i].premium,'')?></td>
					<!-- temp="dataList_template_content" end -->
				</tr>
				<?}?>
			</script>

			<!-- Part 三、 以下是js模块区域 -->
			<script>
				var clickMenu = "statistics-order-list";
				var myPage, dataListId, searchFormId;
				myPage = 10;//定义列表数据
				dataListId = "dataList";//显示列表数据div的id
				searchFormId = "searchForm";//搜索表单Id
				/**
				 * 初始化数据字典，id传入#id 返回值Map用法：dictListMap["userType"][rows[i].userType]
				 */
				var dictListMap = DictUtil.initDictAndDymic();

				$(function () {
					//1、加载分页列表数据
					getTableData();

					//2、控制是否启用token
					//setToken();

				});

				$(function () {
					//设置数据行选中效果
					$('#' + dataListId + ' tbody').on('click', 'tr', function (e) {
						if ($(this).hasClass('selected')) {
						} else {
							$('tr.selected').removeClass('selected');
							$(this).addClass('selected');
						}
						//var id = $('tr.selected th').eq(0).html();
					});
				});
				//注入日历框样式
				var dateObject = $('.datepicker').datepicker({
					language: 'zh-CN',
					//inline: true,
					todayBtn: "linked",
					format: "yyyy-mm-dd",
					autoclose: true
				});

				//数据toLoad读取（查看、编辑）数据
				function toLoad(obj, type) {
					var inputPrimaryObj = $(obj).parent().parent().find("input[name='input_primaryKey']");
					if (inputPrimaryObj.length > 0) {
						var reqUrl = "";
						if ("view" == type) {
							var reqUrl = $("#viewForm_hidden").find("input[name='location']").val();
							if (strUtil.isNull(reqUrl)) {
								layer.alert("缺失跳转查看地址参数！");
								return;
							}
						} else if ("edit" == type) {
							var reqUrl = $("#editForm_hidden").find("input[name='location']").val();
							if (strUtil.isNull(reqUrl)) {
								layer.alert("缺失跳转修改地址参数！");
								return;
							}
						}
						var paramData = "f=" + new Date().getTime();
						for (var k = 0; k < inputPrimaryObj.length; k++) {
							var pkobj = $(inputPrimaryObj[k]);
							paramData += "&" + pkobj.attr("primary") + "=" + pkobj.val();
						}
						var pageUrl = ctx + reqUrl + "?" + paramData;
						mytools.pjax(pageUrl);
					}
				}

				//删除调用
				function toDele(obj) {
					if (!$("#delForm_hidden").find("input[name='formName']").val()) {
						layer.alert("缺失删除参数！");
						return;
					}
					var index_submit = layer.confirm("您确定要删除信息吗？", {btn: ["Yes", "No"], closeBtn: 0, offset: "220px"}
							, function () {
								layer.close(index_submit);
								var paramData = {};
								var inputPrimaryObj = $(obj).parent().parent().find("input[name='input_primaryKey']");
								paramData["pageName"] = $("#delForm_hidden").find("input[name='pageName']").val();
								paramData["formName"] = $("#delForm_hidden").find("input[name='formName']").val();
								if (inputPrimaryObj.length > 0) {
									for (var k = 0; k < inputPrimaryObj.length; k++) {
										var pkobj = $(inputPrimaryObj[k]);
										paramData[pkobj.attr("obj-name") + ".w_" + pkobj.attr("primary")] = pkobj.val();
									}
									$.ajax({
										type: "post",
										url: common_submit_url,
										data: paramData, dataType: "json",
										success: function (myData) {
											var result = myData.flag;
											if (result == "T") {
												refresh();
											} else {
												layer.alert("删除失败！");
											}
										}
									});
								}
							});
				}

				//加载列表数据
				function getTableData() {
					if (strUtil.isNull($("#" + searchFormId).find("input[name='pageName']").val())) {
						return;
					}
					var index_load = layer.load(1, {shade: false});
					$.ajax({
						type: 'get',
						url: common_list_url,
						data: $("#" + searchFormId).serialize() + getCurrentPage(common_list_url + "?" + $("#" + searchFormId).serialize(), myPage),
						dataType: 'json',
						success: function (myData) {
							console.log(myData);
							var data = baidu.template(dataListId + "-template", eval(myData));
							$("#" + dataListId + "-body").html(data);
							var option = {
								ele: $("#" + dataListId + "-page")[0],
								total: myData.total,
								fn: getTableData,
								url: common_list_url + "?" + $("#" + searchFormId).serialize()
							}
							generatePages(option);
							layer.close(index_load);
						}
					});
				}
				function toOut() {
					var index_load = layer.load(1, {shade: false});
					$.ajax({
						type: 'post',
						url: "${ctx}/outexcel",
						data: $("#" + searchFormId).serialize(),
						dataType: 'json',
						success: function (myData) {
							layer.close(index_load);
							console.log(myData,"outexcel");
							// var downloadUrl = 'http://'+hostname+':11080/atta/labf/out12345Test.xls'
							window.open(myData.msg);
						}
					})
				}

				//刷新
				function refresh() {
					getTableData();
				}

				//设置token
				function setToken() {
					$.ajax({
						type: 'get',
						url: '${ctx}/sendPage/token?token=true',
						dataType: 'text',
						success: function (myData) {
							console.log(myData);
							$('.formToken').val(myData);
						}
					});
				}


			</script>
		</section>
		<!-- Main end -->
	</div>
	<!-- foot start -->
	<%@include file="/common/ssb/foot.jsp" %>
	<!-- foot start -->
</div>
<!-- /.content-wrapper -->
</body>
</html>







